package no.idi.ntnu.owl;

import java.util.ArrayList;

import com.hp.hpl.jena.ontology.OntClass;
import com.hp.hpl.jena.ontology.OntModel;
import com.hp.hpl.jena.rdf.model.RDFNode;
import com.hp.hpl.jena.util.iterator.ExtendedIterator;

public class ICD10Search {
	
	public ArrayList<RDFNode> searchByLabel(OntModel ontologyModel, String search)
	{
		search = search.toLowerCase();
		ArrayList<RDFNode> resultList = new ArrayList<RDFNode>();
		ExtendedIterator iterator = ontologyModel.listClasses();
		while (iterator.hasNext()) {
			OntClass thisClass = (OntClass) iterator.next();
			ExtendedIterator label = thisClass.listLabels(null);
			
	        while (label.hasNext()) {
	            RDFNode thisLabel = (RDFNode) label.next();
	            if(thisLabel.toString().toLowerCase().contains(search)){
	            	resultList.add(thisLabel);
	            }
	          }
		}
		return resultList;
	}
	

}
